import components.clPrintImeiList;
import components.clPrintPayment;
import components.clPrintPriceList;

import mx.printing.FlexPrintJob;
import mx.printing.FlexPrintJobScaleType;

 private function clDoPrintPriceList():void{
 	/*
	var printJob:FlexPrintJob = new FlexPrintJob();
	if (printJob.start() != true) return;
	printJob.addObject(obiect, FlexPrintJobScaleType.NONE);
	printJob.send();
	*/
	var printJob:FlexPrintJob = new FlexPrintJob();
	printJob.printAsBitmap = false;
            
            // Start the print job.
            if (printJob.start()) {
                // Create a FormPrintView control 
                // as a child of the application.
                var thePrintView:clPrintPriceList = new clPrintPriceList();
                this.addChild(thePrintView);
                
                // Set the print view properties.
                thePrintView.width=printJob.pageWidth;
                thePrintView.height=printJob.pageHeight;
                
                // Set the data provider of the FormPrintView 
                // component's DataGrid to be the data provider of 
                // the displayed DataGrid.
                thePrintView.myDataGrid.dataProvider = clDgPriceList.dataProvider;
                
                // Create a single-page image.
                thePrintView.showPage();
                
                // If the print image's DataGrid can hold all the  
                // data provider's rows, add the page to the print job. 
                if(!thePrintView.myDataGrid.validNextPage)
                {
                    printJob.addObject(thePrintView, FlexPrintJobScaleType.NONE);
                }
                // Otherwise, the job requires multiple pages.
                else
                {
                    // Create the first page and add it to the print job.
                    thePrintView.showPage();
                    printJob.addObject(thePrintView, FlexPrintJobScaleType.NONE);
                    thePrintView.pageBottom++;
                    
                    // Loop through the following code 
                    // until all pages are queued.
                    while(true)
                    {
                        // Move the next page of data to the top of 
                        // the PrintDataGrid.
                        thePrintView.myDataGrid.nextPage();

                        // Try creating a last page.
                        thePrintView.showPage();  

                        // If the page holds the remaining data, or if 
                        // the last page was completely filled by the last  
                        // grid data, queue it for printing.
                        // Test if there is data for another 
                        // PrintDataGrid page.
                        if(!thePrintView.myDataGrid.validNextPage) 
                        {
                            // This is the last page; 
                            // queue it and exit the print loop.
                            printJob.addObject(thePrintView);
                            break;
                        }
                        else
                        // This is not the last page. Queue a middle page. 
                        {
                            thePrintView.showPage();
                            printJob.addObject(thePrintView, FlexPrintJobScaleType.NONE);
                            thePrintView.pageBottom++;                            
                        }
                    }
                }
                // All pages are queued; remove the FormPrintView 
                // control to free memory.
                this.removeChild(thePrintView);
            }
            // Send the job to the printer.
            printJob.send();

}
private function clDoPrintPayment():void{
	var printJob:FlexPrintJob = new FlexPrintJob();
	printJob.printAsBitmap = false;
            
            // Start the print job.
            if (printJob.start()) {
                // Create a FormPrintView control 
                // as a child of the application.
                var thePrintView:clPrintPayment = new clPrintPayment();
                this.addChild(thePrintView);
                
                // Set the print view properties.
                thePrintView.width=printJob.pageWidth;
                thePrintView.height=printJob.pageHeight;
                
                // Set the data provider of the FormPrintView 
                // component's DataGrid to be the data provider of 
                // the displayed DataGrid.
                thePrintView.myDataGrid.dataProvider = clDgPayment.dataProvider;
                
                // Create a single-page image.
                thePrintView.showPage();
                
                // If the print image's DataGrid can hold all the  
                // data provider's rows, add the page to the print job. 
                if(!thePrintView.myDataGrid.validNextPage)
                {
                    printJob.addObject(thePrintView);
                }
                // Otherwise, the job requires multiple pages.
                else
                {
                    // Create the first page and add it to the print job.
                    thePrintView.showPage();
                    printJob.addObject(thePrintView);
                    thePrintView.pageBottom++;
                    
                    // Loop through the following code 
                    // until all pages are queued.
                    while(true)
                    {
                        // Move the next page of data to the top of 
                        // the PrintDataGrid.
                        thePrintView.myDataGrid.nextPage();

                        // Try creating a last page.
                        thePrintView.showPage();  

                        // If the page holds the remaining data, or if 
                        // the last page was completely filled by the last  
                        // grid data, queue it for printing.
                        // Test if there is data for another 
                        // PrintDataGrid page.
                        if(!thePrintView.myDataGrid.validNextPage) 
                        {
                            // This is the last page; 
                            // queue it and exit the print loop.
                            printJob.addObject(thePrintView);
                            break;
                        }
                        else
                        // This is not the last page. Queue a middle page. 
                        {
                            thePrintView.showPage();
                            printJob.addObject(thePrintView);
                            thePrintView.pageBottom++;                            
                        }
                    }
                }
                // All pages are queued; remove the FormPrintView 
                // control to free memory.
                this.removeChild(thePrintView);
            }
            // Send the job to the printer.
            printJob.send();

}
private function clDoPrintImeiList():void{
	var printJob:FlexPrintJob = new FlexPrintJob();
	printJob.printAsBitmap = false;
            
            // Start the print job.
            if (printJob.start()) {
                // Create a FormPrintView control 
                // as a child of the application.
                var thePrintView:clPrintImeiList = new clPrintImeiList();
                this.addChild(thePrintView);
                
                // Set the print view properties.
                thePrintView.width=printJob.pageWidth;
                thePrintView.height=printJob.pageHeight;
                
                // Set the data provider of the FormPrintView 
                // component's DataGrid to be the data provider of 
                // the displayed DataGrid.
                thePrintView.myDataGrid.dataProvider = clDgListImei.dataProvider;
                
                // Create a single-page image.
                thePrintView.showPage();
                
                // If the print image's DataGrid can hold all the  
                // data provider's rows, add the page to the print job. 
                if(!thePrintView.myDataGrid.validNextPage)
                {
                    printJob.addObject(thePrintView);
                }
                // Otherwise, the job requires multiple pages.
                else
                {
                    // Create the first page and add it to the print job.
                    thePrintView.showPage();
                    printJob.addObject(thePrintView);
                    thePrintView.pageBottom++;
                    
                    // Loop through the following code 
                    // until all pages are queued.
                    while(true)
                    {
                        // Move the next page of data to the top of 
                        // the PrintDataGrid.
                        thePrintView.myDataGrid.nextPage();

                        // Try creating a last page.
                        thePrintView.showPage();  

                        // If the page holds the remaining data, or if 
                        // the last page was completely filled by the last  
                        // grid data, queue it for printing.
                        // Test if there is data for another 
                        // PrintDataGrid page.
                        if(!thePrintView.myDataGrid.validNextPage) 
                        {
                            // This is the last page; 
                            // queue it and exit the print loop.
                            printJob.addObject(thePrintView);
                            break;
                        }
                        else
                        // This is not the last page. Queue a middle page. 
                        {
                            thePrintView.showPage();
                            printJob.addObject(thePrintView);
                            thePrintView.pageBottom++;                            
                        }
                    }
                }
                // All pages are queued; remove the FormPrintView 
                // control to free memory.
                this.removeChild(thePrintView);
            }
            // Send the job to the printer.
            printJob.send();

}